<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增售卖</title>
    <link href="../plugin/bootstrap-3.3.7-dist/css/bootstrap.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../plugin/jquery/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="../plugin/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
    <script type="text/javascript" src="../plugin/layer/layer.js"></script>
    <script type="text/javascript" src="../base.js"></script>
    <style>
        button {
            margin-left: 10px;
        }
    </style>
</head>
<body>
<form style="margin:10px">
    <div class="form-group">
        <label for="title">标题</label>
        <input type="text" class="form-control" id="title"/>
    </div>
    <div class="form-group">
        <label for="content">内容</label>
        <textarea type="text" class="form-control" style="height:100px" id="content"></textarea>
    </div>
    <div class="form-group">
        <label for="nickName">发布人</label>
        <input type="text" class="form-control" id="nickName"/>
    </div>
    <div class="form-group">
        <label for="code">游戏编号</label>
        <input type="text" class="form-control" id="code"/>
    </div>
    <div class="form-group">
        <label for="galaxy">所在星系</label>
        <input type="text" class="form-control" id="galaxy"/>
    </div>
</form>
<div class="form-group">
    <button type="submit" class="btn btn-primary" onclick="publish()">发布</button>
</div>
</body>
<script>

    let type = 2;

    //获取列表
    function publish() {
        $.ajax({
            url: domain + '/market/publish',
            type: 'post',
            dataType: 'json',
            data: {
                'title': $('#title').val(),
                'content': $('#content').val(),
                'nickName': $('#nickName').val(),
                'code': $('#code').val(),
                'galaxy': $('#galaxy').val(),
                'type': type
            },
            success: function (data) {
                if (data.code === 0) {
                    let index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.location.reload();
                } else {
                    layer.msg(data.msg);
                }
            }
        })
    }
</script>
</html>